<%@page import="com.entity.Document"%>
<%@page import="com.entity.Project"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>编辑资料</title>

</head>
<body>
	
	<%
		Document document=(Document)request.getSession().getAttribute("document");
	 %>

	<div class="container well" style="width:800px">
		<h1>编辑资料</h1>
		
		<div>
			<form id="form"action="updatedocument.jspx" method="post" class="form-horizontal well">
						<div class="form-inline">
							<label>标题</label><br>
							<input style="height:30px" type="text" class="input-xlarge" id="documenttitle" value="<%=document.getTitle() %>" placeholder="请输入文档名称" name = "documenttitle">
							<span style="color:red" id="title_msg"></span>
						</div>
						
						<br /><br />
						<label>内容</label>
						<textarea rows="6" id="textarea" class="span10"  placeholder="请输入文档的描述" name = "documentcontent"><%=document.getContent() %></textarea>
						<span style="color:red" id="content_msg"></span>
						<br /><br />
				
						<div class="form-actions" style="padding-left:324px">
							<button class="btn btn-primary btn-large" type="submit">保存</button>
							<a class="btn btn-large" href="document.jspx">返回</a>
						</div>
			</form>
		</div>
	</div>
	
</body>

<script type="text/javascript">
		//document.getElementById("validateForm").onclick=function(){
		
		document.getElementById("form").onsubmit=function(){
			
			var title = document.getElementById("documenttitle").value;
			var content = document.getElementById("textarea").value;

			if(title.trim() == "") {
				document.getElementById("title_msg").innerHTML = "请输入资料标题";
				document.getElementById("documenttitle").focus();
				return false;
			}
			if(content == "") {
				document.getElementById("content_msg").innerHTML = "请输入资料内容";
				document.getElementById("documenttitle").focus();
				return false;
			}
		};
		
		document.getElementById("documenttitle").onblur = function(){
		
			var title = document.getElementById("documenttitle").value;
			if(title.trim() == "") {
				document.getElementById("documenttitle").value = "";
				document.getElementById("title_msg").innerHTML = "请输入资料标题";
				document.getElementById("documenttitle").focus();
			}else{
				document.getElementById("title_msg").innerHTML = "";
			}
		};
		document.getElementById("documenttitle").onblur = function(){
		
			var title = document.getElementById("documenttitle").value;
			if(title.trim() == "") {
				document.getElementById("documenttitle").value = "";
				document.getElementById("title_msg").innerHTML = "请输入资料内容";
				document.getElementById("documenttitle").focus();
			}else{
				document.getElementById("content_msg").innerHTML = "";
			}
		};
		document.getElementById("documenttitle").onkeydown = function(){
			document.getElementById("title_msg").innerHTML = "";
		};
		document.getElementById("textarea").onkeydown = function(){
			document.getElementById("content_msg").innerHTML = "";
		};

	</script>
</html>